# this is the main payment manager module
# 
# any action that only admin user can perform should
# have a wrapper here

from __init__ import Singleton

from ptObject.user import *
from ptObject.payment import *

class Manager(object):
    """
    payment manager class
    This is a singleton class. You can only have one instance of this
    class. However, this shouldn't matter at all, since all other
    ptObject classes are multiton classes
    """
    __metaclass__ = Singleton

    ######## Overridden build-in Methods / Operators ########
    def __init__(self):
        pass                    # we do not need to construct anything, yet

    ######## Public Functions ########
    def createUser(self, name):
        return User(name)

    def renameUser(self, oldName, newName):
        try:
            usr = User.getUser(oldName)
            usr.changeName(newName)
        except:
            return False
        return True

    def activateUser(self, name, active):
        usr = User(name)
        if usr:
            if active:
                usr.activate()
            else:
                usr.deactivate()
            return usr.isActive()
        return None


    ######## Private Member Functions ########

